<template>
	<view>
		<navbar :backshow="true" :title="title" :navBarHeight="navBarHeight" :menuRight="menuRight" :menuTop="menuTop"
			:menuHeight="menuHeight"></navbar>
		<!-- 头部展位 -->
		<view class="main" :style="{ height: mainheight + 'px' }"></view>
		<view class="noticebox">
			<view class="noticeitem" v-for="item in noticelistdata" :key="item.notifyId" @click="noticefn(item)">
				<view class="noticeicon">
					<view class="notice" v-if="item.readStatus ==9">

					</view>
					<image src="@/static/notiles.png" mode=""></image>
				</view>
				<view class="noticetitle">
					{{item.title}}
				</view>
				<view class="noticetime">
					{{item.createTime}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: "通知列表",
				navBarHeight: 80, // 导航栏高度
				menuRight: 20, // 胶囊距右方间距（方保持左、右间距一致）
				menuTop: 50, // 胶囊距底部间距（保持底部间距一致）
				menuHeight: 0, // 胶囊高度（自定义内容可与胶囊高度保证一致）
				mainheight: 60,
				pageNum: 1,
				pageSize: 20,
				noticelistdata: []
			}
		},
		onShow() {
			this.$myRequest({
				url: '/client/appointmentUser/notifyList',
				data: {
					pageNum: this.pageNum,
					pageSize: this.pageSize
				}
			}).then((res) => {
				this.noticelistdata = res.data.list
				console.log('获取通知列表', res.data);
			})
		},
		onLoad() {
			const that = this;

			// 获取系统信息
			const systemInfo = wx.getSystemInfoSync();
			// 胶囊按钮位置信息
			const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
			// 导航栏高度 = 状态栏高度 + 44
			that.navBarHeight = systemInfo.statusBarHeight + 44;
			that.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
			that.menuTop = menuButtonInfo.top;
			that.menuHeight = menuButtonInfo.height;
			that.mainheight = menuButtonInfo.top + menuButtonInfo.height;
			// 获取一下 最新数据

			this.$myRequest({
				url: '/client/appointmentUser/notifyList',
				data: {
					pageNum: this.pageNum,
					pageSize: this.pageSize
				}
			}).then((res) => {
				this.noticelistdata = res.data.list
				console.log('获取通知列表', res.data);
			})

		},
		onReachBottom() {
			this.pageNum = this.pageNum + 1;
			this.roombookingfns();
			console.log("触底函数");
		},
		methods: {
			noticefn(item) {
				// 存储到本地进行跳转
				uni.setStorage({
					key: "noticedata",
					data: item,
					success: () => {
						console.log("数据存储成功");
						uni.navigateTo({
							url: "/pages/noticexq/noticexq", // 要跳转的非 tabBar 页面路径，可以带参数
						});
					},
				});
			},
			roombookingfns() {
				this.$myRequest({
					url: "/client/appointment/roomAppointmentRecord",
					method: "get",
					data: {
						pageNum: this.pageNum,
						pageSize: this.pageSize,
					},
				}).then((res) => {
					console.log("获取通知列表", res.data);
					// this.roombookings = res.data.list;

					const newListData = [...this.noticelistdata, ...res.data.list];
					this.noticelistdata = newListData;
				});
			},
		}
	}
</script>

<style>

</style>